<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var reverseList = function (head) {
        if (!head) return head
        let dummy = new ListNode(0, head)
        let pre = dummy
        let cur = head
        //pre-1-2-3-4-5
        while (cur) {
          let next = cur.next
          cur.next = pre
          pre = cur
          cur = next
        }
        //最后会多个0节点
        head.next = null
        return pre
      }
    </script>
  </body>
</html>
